import { createRouter,createWebHashHistory,createWebHistory} from 'vue-router'
// 路由函数
import {Home,Login} from './routes'

const routes = [
    {
		path: '/',
		name:'home',
        component:Home
	},
	{
		path: '/login',
		name: 'login',
		component: Login
	}
]
 
// router实例
const router = createRouter({
	history: createWebHistory(), //hash模式（若使用history模式改为createWebHashHistory()）
	routes,
});
 
 
// 全局前置守卫
router.beforeEach((to, from, next) => {
	next();
});
 
// 全局解析守卫
router.beforeResolve(async to => {});
 
// 全局后置钩子
router.afterEach((to, from, failure) => {
	console.log(to);
	// router.push('login')
	
	// if (!failure) sendToAnalytics(to.fullPath)
    
});
 
export default router